package com.xiaotao.service.impl;

import com.xiaotao.entity.Admin;
import com.xiaotao.entity.Merchant;
import com.xiaotao.mapper.AdminMapper;
import com.xiaotao.service.AdminService;
import com.xiaotao.util.ResponseEnum;
import com.xiaotao.util.ResponseUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class AdminServiceImpl implements AdminService {
    @Resource
    private AdminMapper adminMapper;
    @Override
    public ResponseUtil login(Admin admin) {
        if (admin.getUsername().isEmpty()||admin.getPassword().isEmpty()){
            return ResponseUtil.get(ResponseEnum.FAIL,"商户用户密码不能为空");
        }
        //根据用户名查询密码
        Admin admin1 = adminMapper.findByUsername(admin.getUsername());
        if (!admin.getPassword().equals(admin1.getPassword())){
            //密码错误
            return ResponseUtil.get(ResponseEnum.FAIL,"密码或者用户名错误");
        }
        return ResponseUtil.get(ResponseEnum.OK,"登录成功");
    }
}
